<!DOCTYPE html> 
<html>
<head>
  <title>Pong!</title> 
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
  <link href="pong.css" media="screen, print" rel="stylesheet" type="text/css" /> 
</head> 
 
<body> 

  <div id="sidebar">

    <h2>经典街机游戏Pong的javascript版本！</h2>

    <ul class='parts'>
      <li><a href='#' class='selected'>重新开始游戏</a></li>
      <li><a href='/part1'><i>游戏Runner</i> - Part 1</a></li>
      <li><a href='/part2'><i>弹跳球</i> - Part 2</a></li>
      <li><a href='/part3'><i>游戏循环</i> - Part 3</a></li>
      <li><a href='/part4'><i>碰撞检测</i> - Part 4</a></li>
      <li><a href='/part5'><i>人工智能的实现</i> - Part 5</a></li>
    </ul>

    <div class='description'>
     <p>
这是Pong的javascript版本。
    </p>
    <p>
按<b>1</b>可玩单人游戏。<br>
按<b>2</b>可玩双人游戏。<br>
按<b>0</b>可观看电脑（AI）玩游戏。
</p>
<p>
玩家1使用<b>Q</b>和<b>A</b>键移动。<br>
玩家2使用<b>P</b>和<b>L</b>键移动。
</p>
<p>
<b>Esc</b>可用于放弃游戏。
</p>
    </div>

    <div class='settings'>
      <label for='sound'>声音：</label>
      <input type='checkbox' id='sound'>
    </div>

    <div class='settings'>
      <label for='stats'>统计信息： </label>
      <input type='checkbox' id='stats' checked>
    </div>

    <div class='settings'>
      <label for='footprints'>痕迹： </label>
      <input type='checkbox' id='footprints' checked>
    </div>

    <div class='settings'>
      <label for='predictions'>预测：</label>
      <input type='checkbox' id='predictions'>
    </div>

  </div>

  <canvas id="game">
    <div id="unsupported">
      很抱歉，无法运行，因为您的浏览器不支持&amp;canvas&amp;元素
    </div>
  </canvas>

  <script src="game.js" type="text/javascript"></script> 
  <script src="pong.js" type="text/javascript"></script>
  <script type="text/javascript">
  Game.ready(function() {

    var size        = document.getElementById('size');
    var sound       = document.getElementById('sound');
    var stats       = document.getElementById('stats');
    var footprints  = document.getElementById('footprints');
    var predictions = document.getElementById('predictions');

    var pong = Game.start('game', Pong, {
      sound:       sound.checked,
      stats:       stats.checked,
      footprints:  footprints.checked,
      predictions: predictions.checked
    });

    Game.addEvent(sound,       'change', function() { pong.enableSound(sound.checked);           });
    Game.addEvent(stats,       'change', function() { pong.showStats(stats.checked);             });
    Game.addEvent(footprints,  'change', function() { pong.showFootprints(footprints.checked);   });
    Game.addEvent(predictions, 'change', function() { pong.showPredictions(predictions.checked); });

  });
  </script>

</body> 
</html>
